**#Table B.1. 

use "$Folder/Data_Civil_Servants_final.dta", clear

mat T = J(21,10,.)

sum business_days if time==0 
mat T[1,1] = r(mean)
mat T[1,2] = r(sd)
sum business_days  if time==0 & treatment==0
mat T[1,3] = r(mean)
mat T[1,4] = r(sd)
sum business_days  if time==0 & treatment==1
mat T[1,5] = r(mean)
mat T[1,6] = r(sd)
mat T[1,7] = T[1,5] - T[1,3]

sum business_w5 if time==0 
mat T[2,1] = r(mean)
mat T[2,2] = r(sd)
sum business_w5  if time==0 & treatment==0
mat T[2,3] = r(mean)
mat T[2,4] = r(sd)
sum business_w5  if time==0 & treatment==1
mat T[2,5] = r(mean)
mat T[2,6] = r(sd)
mat T[2,7] = T[2,5] - T[2,3]

sum in_time_original if time==0 
mat T[3,1] = r(mean)
mat T[3,2] = r(sd)
sum in_time_original  if time==0 & treatment==0
mat T[3,3] = r(mean)
mat T[3,4] = r(sd)
sum in_time_original  if time==0 & treatment==1
mat T[3,5] = r(mean)
mat T[3,6] = r(sd)
mat T[3,7] = T[3,5] - T[3,3]

sum comply if time==0 
mat T[4,1] = r(mean)
mat T[4,2] = r(sd)
sum comply if time==0 & treatment==0
mat T[4,3] = r(mean)
mat T[4,4] = r(sd)
sum comply if time==0 & treatment==1
mat T[4,5] = r(mean)
mat T[4,6] = r(sd)
mat T[4,7] = T[4,5] - T[4,3]

sum complete if time==0 
mat T[5,1] = r(mean)
mat T[5,2] = r(sd)
sum complete  if time==0 & treatment==0
mat T[5,3] = r(mean)
mat T[5,4] = r(sd)
sum complete  if time==0 & treatment==1
mat T[5,5] = r(mean)
mat T[5,6] = r(sd)
mat T[5,7] = T[5,5] - T[5,3]

sum open_request if time==0 
mat T[6,1] = r(mean)
mat T[6,2] = r(sd)
sum open_request if time==0 & treatment==0
mat T[6,3] = r(mean)
mat T[6,4] = r(sd)
sum open_request if time==0 & treatment==1
mat T[6,5] = r(mean)
mat T[6,6] = r(sd)
mat T[6,7] = T[6,5] - T[6,3]

sum extension if time==0 
mat T[7,1] = r(mean)
mat T[7,2] = r(sd)
sum extension if time==0 & treatment==0
mat T[7,3] = r(mean)
mat T[7,4] = r(sd)
sum extension if time==0 & treatment==1
mat T[7,5] = r(mean)
mat T[7,6] = r(sd)
mat T[7,7] = T[7,5] - T[7,3]

sum business_days_within_15 if time==0 
mat T[8,1] = r(mean)
mat T[8,2] = r(sd)
sum business_days_within_15 if time==0 & treatment==0
mat T[8,3] = r(mean)
mat T[8,4] = r(sd)
sum business_days_within_15 if time==0 & treatment==1
mat T[8,5] = r(mean)
mat T[8,6] = r(sd)
mat T[8,7] = T[8,5] - T[8,3]

sum business_days_within_25 if time==0 
mat T[9,1] = r(mean)
mat T[9,2] = r(sd)
sum business_days_within_25 if time==0 & treatment==0
mat T[9,3] = r(mean)
mat T[9,4] = r(sd)
sum business_days_within_25 if time==0 & treatment==1
mat T[9,5] = r(mean)
mat T[9,6] = r(sd)
mat T[9,7] = T[9,5] - T[9,3]

sum business_days_15 if time==0 
mat T[10,1] = r(mean)
mat T[10,2] = r(sd)
sum business_days_15  if time==0 & treatment==0
mat T[10,3] = r(mean)
mat T[10,4] = r(sd)
sum business_days_15  if time==0 & treatment==1
mat T[10,5] = r(mean)
mat T[10,6] = r(sd)
mat T[10,7] = T[10,5] - T[10,3]

sum business_days_25 if time==0 
mat T[11,1] = r(mean)
mat T[11,2] = r(sd)
sum business_days_25  if time==0 & treatment==0
mat T[11,3] = r(mean)
mat T[11,4] = r(sd)
sum business_days_25  if time==0 & treatment==1
mat T[11,5] = r(mean)
mat T[11,6] = r(sd)
mat T[11,7] = T[11,5] - T[11,3]

sum business_days_141516 if time==0 
mat T[12,1] = r(mean)
mat T[12,2] = r(sd)
sum business_days_141516 if time==0 & treatment==0
mat T[12,3] = r(mean)
mat T[12,4] = r(sd)
sum business_days_141516 if time==0 & treatment==1
mat T[12,5] = r(mean)
mat T[12,6] = r(sd)
mat T[12,7] = T[12,5] - T[12,3]

sum business_days_242526 if time==0 
mat T[13,1] = r(mean)
mat T[13,2] = r(sd)
sum business_days_242526  if time==0 & treatment==0
mat T[13,3] = r(mean)
mat T[13,4] = r(sd)
sum business_days_242526  if time==0 & treatment==1
mat T[13,5] = r(mean)
mat T[13,6] = r(sd)
mat T[13,7] = T[13,5] - T[13,3]

sum business_days_late if time==0 
mat T[16,1] = r(mean)
mat T[16,2] = r(sd)
sum business_days_late if time==0 & treatment==0
mat T[16,3] = r(mean)
mat T[16,4] = r(sd)
sum business_days_late if time==0 & treatment==1
mat T[16,5] = r(mean)
mat T[16,6] = r(sd)
mat T[16,7] = T[16,5] - T[16,3]

sum agency_n_req_date if time==0 
mat T[17,1] = r(mean)
mat T[17,2] = r(sd)
sum agency_n_req_date if time==0 & treatment==0
mat T[17,3] = r(mean)
mat T[17,4] = r(sd)
sum agency_n_req_date if time==0 & treatment==1
mat T[17,5] = r(mean)
mat T[17,6] = r(sd)
mat T[17,7] = T[17,5] - T[17,3]

sum perc_closed if time==0 
mat T[18,1] = r(mean)
mat T[18,2] = r(sd)
sum perc_closed if time==0 & treatment==0
mat T[18,3] = r(mean)
mat T[18,4] = r(sd)
sum perc_closed if time==0 & treatment==1
mat T[18,5] = r(mean)
mat T[18,6] = r(sd)
mat T[18,7] = T[18,5] - T[18,3]

sum perc_open_not_expired if time==0 
mat T[19,1] = r(mean)
mat T[19,2] = r(sd)
sum perc_open_not_expired if time==0  & treatment==0
mat T[19,3] = r(mean)
mat T[19,4] = r(sd)
sum perc_open_not_expired if time==0  & treatment==1
mat T[19,5] = r(mean)
mat T[19,6] = r(sd)
mat T[19,7] = T[19,5] - T[19,3]

sum perc_open_expired if time==0 
mat T[20,1] = r(mean)
mat T[20,2] = r(sd)
sum perc_open_expired if time==0 & treatment==0
mat T[20,3] = r(mean)
mat T[20,4] = r(sd)
sum perc_open_expired if time==0 & treatment==1
mat T[20,5] = r(mean)
mat T[20,6] = r(sd)
mat T[20,7] = T[20,5] - T[20,3]

preserve 
collapse total_requests, by(agency treatment)
sum total_requests
mat T[21,1] = r(mean)
mat T[21,2] = r(sd)
sum total_requests if treatment==0
mat T[21,3] = r(mean)
mat T[21,4] = r(sd)
sum total_requests if treatment==1
mat T[21,5] = r(mean)
mat T[21,6] = r(sd)
mat T[21,7] = T[21,5] - T[21,3]

foreach var in total_requests {
reg `var' treatment, cluster(agency) 
loc t = _b[treatment]/_se[treatment]
loc p_`var' = 2*ttail(e(df_r),abs(`t'))			
}

restore


foreach var in business_days business_w5 in_time_original comply complete open_request extension business_days_within_15 business_days_within_25 business_days_15 business_days_25 business_days_141516 business_days_242526 business_days_late agency_n_req_date perc_closed perc_open_not_expired perc_open_expired {
reg `var' treatment if time==0, cluster(agency) 
loc t = _b[treatment]/_se[treatment]
loc p_`var' = 2*ttail(e(df_r),abs(`t'))			
}

mat T[1,9] = `p_business_days'
mat T[2,9] = `p_business_w5' 
mat T[3,9] = `p_in_time_original'
mat T[4,9] = `p_comply'
mat T[5,9] = `p_complete' 
mat T[6,9] = `p_open_request' 
mat T[7,9] = `p_extension' 
mat T[8,9] = `p_business_days_within_15' 
mat T[9,9] = `p_business_days_within_25' 
mat T[10,9] = `p_business_days_15' 
mat T[11,9] = `p_business_days_25' 
mat T[12,9] = `p_business_days_141516' 
mat T[13,9] = `p_business_days_242526' 
mat T[16,9] = `p_business_days_late' 
mat T[17,9] = `p_agency_n_req_date'
mat T[18,9] = `p_perc_closed'
mat T[19,9] = `p_perc_open_not_expired'
mat T[20,9] = `p_perc_open_expired'
mat T[21,9] = `p_total_requests'

matlist T

mat rownames T = "Business days" "Business days w5" "Response in time (original)" "Response in time" "Complete response" "Open request by Nov. 27, 2019" "Extension was granted" "Replied within 15 business days" "Replied within 25 business days" "Replied in 15 business days" "Replied in 25 business days"  "Replied in 14/15/16 business" "Replied in 24/25/26 bus" " " " " "Replied in more than 25 bus"  "N requests received on a day"   "Closed requests when new arrived" "Pending requests (not expired)" "Backlog" "Total requests"       
               
frmttable using "$Tables/Table_B1", tex statmat(T) varlabels replace ctitle("", All, Control, Treatment, Difference, p-value) sdec(3) substat(1) 

**#Table B.2. 

keep if sample==1

mat T = J(21,10,.)

sum business_days if time==0 
mat T[1,1] = r(mean)
mat T[1,2] = r(sd)
sum business_days  if time==0 & treatment==0
mat T[1,3] = r(mean)
mat T[1,4] = r(sd)
sum business_days  if time==0 & treatment==1
mat T[1,5] = r(mean)
mat T[1,6] = r(sd)
mat T[1,7] = T[1,5] - T[1,3]

sum business_w5 if time==0 
mat T[2,1] = r(mean)
mat T[2,2] = r(sd)
sum business_w5  if time==0 & treatment==0
mat T[2,3] = r(mean)
mat T[2,4] = r(sd)
sum business_w5  if time==0 & treatment==1
mat T[2,5] = r(mean)
mat T[2,6] = r(sd)
mat T[2,7] = T[2,5] - T[2,3]

sum in_time_original if time==0 
mat T[3,1] = r(mean)
mat T[3,2] = r(sd)
sum in_time_original  if time==0 & treatment==0
mat T[3,3] = r(mean)
mat T[3,4] = r(sd)
sum in_time_original  if time==0 & treatment==1
mat T[3,5] = r(mean)
mat T[3,6] = r(sd)
mat T[3,7] = T[3,5] - T[3,3]

sum comply if time==0 
mat T[4,1] = r(mean)
mat T[4,2] = r(sd)
sum comply if time==0 & treatment==0
mat T[4,3] = r(mean)
mat T[4,4] = r(sd)
sum comply if time==0 & treatment==1
mat T[4,5] = r(mean)
mat T[4,6] = r(sd)
mat T[4,7] = T[4,5] - T[4,3]

sum complete if time==0 
mat T[5,1] = r(mean)
mat T[5,2] = r(sd)
sum complete  if time==0 & treatment==0
mat T[5,3] = r(mean)
mat T[5,4] = r(sd)
sum complete  if time==0 & treatment==1
mat T[5,5] = r(mean)
mat T[5,6] = r(sd)
mat T[5,7] = T[5,5] - T[5,3]

sum open_request if time==0 
mat T[6,1] = r(mean)
mat T[6,2] = r(sd)
sum open_request if time==0 & treatment==0
mat T[6,3] = r(mean)
mat T[6,4] = r(sd)
sum open_request if time==0 & treatment==1
mat T[6,5] = r(mean)
mat T[6,6] = r(sd)
mat T[6,7] = T[6,5] - T[6,3]

sum extension if time==0 
mat T[7,1] = r(mean)
mat T[7,2] = r(sd)
sum extension if time==0 & treatment==0
mat T[7,3] = r(mean)
mat T[7,4] = r(sd)
sum extension if time==0 & treatment==1
mat T[7,5] = r(mean)
mat T[7,6] = r(sd)
mat T[7,7] = T[7,5] - T[7,3]

sum business_days_within_15 if time==0 
mat T[8,1] = r(mean)
mat T[8,2] = r(sd)
sum business_days_within_15 if time==0 & treatment==0
mat T[8,3] = r(mean)
mat T[8,4] = r(sd)
sum business_days_within_15 if time==0 & treatment==1
mat T[8,5] = r(mean)
mat T[8,6] = r(sd)
mat T[8,7] = T[8,5] - T[8,3]

sum business_days_within_25 if time==0 
mat T[9,1] = r(mean)
mat T[9,2] = r(sd)
sum business_days_within_25 if time==0 & treatment==0
mat T[9,3] = r(mean)
mat T[9,4] = r(sd)
sum business_days_within_25 if time==0 & treatment==1
mat T[9,5] = r(mean)
mat T[9,6] = r(sd)
mat T[9,7] = T[9,5] - T[9,3]

sum business_days_15 if time==0 
mat T[10,1] = r(mean)
mat T[10,2] = r(sd)
sum business_days_15  if time==0 & treatment==0
mat T[10,3] = r(mean)
mat T[10,4] = r(sd)
sum business_days_15  if time==0 & treatment==1
mat T[10,5] = r(mean)
mat T[10,6] = r(sd)
mat T[10,7] = T[10,5] - T[10,3]

sum business_days_25 if time==0 
mat T[11,1] = r(mean)
mat T[11,2] = r(sd)
sum business_days_25  if time==0 & treatment==0
mat T[11,3] = r(mean)
mat T[11,4] = r(sd)
sum business_days_25  if time==0 & treatment==1
mat T[11,5] = r(mean)
mat T[11,6] = r(sd)
mat T[11,7] = T[11,5] - T[11,3]

sum business_days_141516 if time==0 
mat T[12,1] = r(mean)
mat T[12,2] = r(sd)
sum business_days_141516 if time==0 & treatment==0
mat T[12,3] = r(mean)
mat T[12,4] = r(sd)
sum business_days_141516 if time==0 & treatment==1
mat T[12,5] = r(mean)
mat T[12,6] = r(sd)
mat T[12,7] = T[12,5] - T[12,3]

sum business_days_242526 if time==0 
mat T[13,1] = r(mean)
mat T[13,2] = r(sd)
sum business_days_242526  if time==0 & treatment==0
mat T[13,3] = r(mean)
mat T[13,4] = r(sd)
sum business_days_242526  if time==0 & treatment==1
mat T[13,5] = r(mean)
mat T[13,6] = r(sd)
mat T[13,7] = T[13,5] - T[13,3]

sum business_days_late if time==0 
mat T[16,1] = r(mean)
mat T[16,2] = r(sd)
sum business_days_late if time==0 & treatment==0
mat T[16,3] = r(mean)
mat T[16,4] = r(sd)
sum business_days_late if time==0 & treatment==1
mat T[16,5] = r(mean)
mat T[16,6] = r(sd)
mat T[16,7] = T[16,5] - T[16,3]

sum agency_n_req_date if time==0 
mat T[17,1] = r(mean)
mat T[17,2] = r(sd)
sum agency_n_req_date if time==0 & treatment==0
mat T[17,3] = r(mean)
mat T[17,4] = r(sd)
sum agency_n_req_date if time==0 & treatment==1
mat T[17,5] = r(mean)
mat T[17,6] = r(sd)
mat T[17,7] = T[17,5] - T[17,3]

sum perc_closed if time==0 
mat T[18,1] = r(mean)
mat T[18,2] = r(sd)
sum perc_closed if time==0 & treatment==0
mat T[18,3] = r(mean)
mat T[18,4] = r(sd)
sum perc_closed if time==0 & treatment==1
mat T[18,5] = r(mean)
mat T[18,6] = r(sd)
mat T[18,7] = T[18,5] - T[18,3]

sum perc_open_not_expired if time==0 
mat T[19,1] = r(mean)
mat T[19,2] = r(sd)
sum perc_open_not_expired if time==0  & treatment==0
mat T[19,3] = r(mean)
mat T[19,4] = r(sd)
sum perc_open_not_expired if time==0  & treatment==1
mat T[19,5] = r(mean)
mat T[19,6] = r(sd)
mat T[19,7] = T[19,5] - T[19,3]

sum perc_open_expired if time==0 
mat T[20,1] = r(mean)
mat T[20,2] = r(sd)
sum perc_open_expired if time==0 & treatment==0
mat T[20,3] = r(mean)
mat T[20,4] = r(sd)
sum perc_open_expired if time==0 & treatment==1
mat T[20,5] = r(mean)
mat T[20,6] = r(sd)
mat T[20,7] = T[20,5] - T[20,3]

preserve 
collapse total_requests, by(agency treatment)
sum total_requests
mat T[21,1] = r(mean)
mat T[21,2] = r(sd)
sum total_requests if treatment==0
mat T[21,3] = r(mean)
mat T[21,4] = r(sd)
sum total_requests if treatment==1
mat T[21,5] = r(mean)
mat T[21,6] = r(sd)
mat T[21,7] = T[21,5] - T[21,3]

foreach var in total_requests {
reg `var' treatment, cluster(agency) 
loc t = _b[treatment]/_se[treatment]
loc p_`var' = 2*ttail(e(df_r),abs(`t'))			
}

restore


foreach var in business_days business_w5 in_time_original comply complete open_request extension business_days_within_15 business_days_within_25 business_days_15 business_days_25 business_days_141516 business_days_242526 business_days_late agency_n_req_date perc_closed perc_open_not_expired perc_open_expired {
reg `var' treatment if time==0, cluster(agency) 
loc t = _b[treatment]/_se[treatment]
loc p_`var' = 2*ttail(e(df_r),abs(`t'))			
}

mat T[1,9] = `p_business_days'
mat T[2,9] = `p_business_w5' 
mat T[3,9] = `p_in_time_original'
mat T[4,9] = `p_comply'
mat T[5,9] = `p_complete' 
mat T[6,9] = `p_open_request' 
mat T[7,9] = `p_extension' 
mat T[8,9] = `p_business_days_within_15' 
mat T[9,9] = `p_business_days_within_25' 
mat T[10,9] = `p_business_days_15' 
mat T[11,9] = `p_business_days_25' 
mat T[12,9] = `p_business_days_141516' 
mat T[13,9] = `p_business_days_242526' 
mat T[16,9] = `p_business_days_late' 
mat T[17,9] = `p_agency_n_req_date'
mat T[18,9] = `p_perc_closed'
mat T[19,9] = `p_perc_open_not_expired'
mat T[20,9] = `p_perc_open_expired'
mat T[21,9] = `p_total_requests'

matlist T

mat rownames T = "Business days" "Business days w5" "Response in time (original)" "Response in time" "Complete response" "Open request by Nov. 27, 2019" "Extension was granted" "Replied within 15 business days" "Replied within 25 business days" "Replied in 15 business days" "Replied in 25 business days"  "Replied in 14/15/16 business" "Replied in 24/25/26 bus" " " " " "Replied in more than 25 bus"  "N requests received on a day"   "Closed requests when new arrived" "Pending requests (not expired)" "Backlog" "Total requests"       
               
frmttable using "$Tables/Table_B2", tex statmat(T) varlabels replace ctitle("", All, Control, Treatment, Difference, p-value) sdec(3) substat(1) 
